<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="UTF-8" />
    <title>Datetime - Color</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0" />
    <link href="../../../../../css/ionic.bundle.css" rel="stylesheet" />
    <link href="../../../../../css/palettes/dark.class.css" rel="stylesheet" />
    <link href="../../../../../scripts/testing/styles.css" rel="stylesheet" />
    <script src="../../../../../scripts/testing/scripts.js"></script>
    <script type="module" src="../../../../../dist/ionic/ionic.esm.js"></script>
    <style>
      ion-checkbox,
      ion-select {
        margin-inline-start: 10px;
        margin-inline-end: 10px;
      }

      .grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, 250px);
        grid-gap: 20px;
      }

      h2 {
        font-size: 12px;
        font-weight: normal;

        color: #6f7378;

        margin-top: 10px;
        margin-left: 5px;
      }

      ion-datetime {
        box-shadow: 0px 16px 32px rgba(0, 0, 0, 0.25), 0px 8px 16px rgba(0, 0, 0, 0.25);
        border-radius: 8px;
      }

      #color-name::first-letter {
        text-transform: capitalize;
      }
    </style>
  </head>
  <body>
    <ion-app>
      <ion-header translucent="true">
        <ion-toolbar>
          <ion-checkbox>Dark Mode</ion-checkbox>
          <ion-select label="Color" justify="end" slot="end" value="danger">
            <ion-select-option value="primary">Primary</ion-select-option>
            <ion-select-option value="secondary">Secondary</ion-select-option>
            <ion-select-option value="tertiary">Tertiary</ion-select-option>
            <ion-select-option value="success">Success</ion-select-option>
            <ion-select-option value="warning">Warning</ion-select-option>
            <ion-select-option value="danger">Danger</ion-select-option>
          </ion-select>
        </ion-toolbar>
      </ion-header>
      <ion-content class="ion-padding">
        <div class="grid">
          <div class="grid-item">
            <h2 id="color-name">Danger</h2>
            <ion-datetime
              id="color-datetime"
              color="danger"
              value="2022-05-03"
              show-default-title="true"
              show-default-buttons="true"
            ></ion-datetime>
          </div>
        </div>
      </ion-content>
      <script>
        const colorDatetime = document.querySelector('#color-datetime');
        const colorName = document.querySelector('#color-name');
        const colorSelect = document.querySelector('ion-select');
        const darkModeCheckbox = document.querySelector('ion-checkbox');

        colorSelect.addEventListener('ionChange', (ev) => {
          colorDatetime.color = ev.detail.value;
          colorName.innerHTML = ev.detail.value;
        });

        darkModeCheckbox.addEventListener('ionChange', (ev) => {
          document.documentElement.classList.toggle('ion-palette-dark');
        });
      </script>
    </ion-app>
  </body>
</html>
